<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body>
	<!-- Main content -->
	<section class="content" id="menumanage">
		<div _table="menuMaintain"  class="byking-panel">
			<div class="byking-panel-head">
				<div class="byking-panel-left">
					<i class="fa fa-sitemap"></i><font>菜单列表</font>
				</div>
				<div class="byking-panel-right">
					<div class="byking-buts">
						<button @click="custom(index,'addParent')" 
							        class="btn btn-default fa fa-bars" 
							        data-toggle="tooltip" 
							        data-original-title="新增顶级菜单"></button>
						<button @click="refreh" 
							        class="btn btn-default fa fa-repeat" 
							        data-toggle="tooltip" 
							        data-original-title="刷新">
						</button>
					</div>
				</div>
			</div>
			<table class="byking-table byking-table-bordered" id="menutable">
				<thead>
					<tr>
						<th>菜单名称</th>
						<th>菜单链接</th>
						<th>菜单图标</th>
						<th>菜单描述</th>
						<th>排序</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>		
					<tr v-for="(index, item) in page" v-bind:data-tt-parent-id="item.parent_guid" v-show="item.level==1">
						<td style="{{'padding-left:'+ (item.level*15) + 'px'}}">					
							<i class="fa fa-caret-right" v-if="!item.isLeaf" @click="expand(item,$event)" style="width:20px"></i>
							<i v-else></i>
							<font>{{item.menu_name}}</font>
						</td>
						<td>{{item.menu_url}}</td>
						<td>{{item.image}}</td>
						<td>{{item.description}}</td>
						<td>{{item.sorting}}</td>
						<td>
							<button  v-show="item.level!=3" @click="custom(index,'add')"
											class="btn btn-default fa fa-plus"
											data-toggle="tooltip" data-original-title="新增">
							</button>
							<button @click="custom(index,'update')"
													 class="btn btn-default fa fa-edit"
													 data-toggle="tooltip" data-original-title="修改">
							</button>
							<button @click="custom(index,'delete')"
												 class="btn btn-default fa fa-remove"
												 data-toggle="tooltip" data-original-title="删除">
							</button>
						</td>
					</tr>
					
					<tr class="data-empty" v-if="page == null">
						<td colspan="7">没有数据</td>
					</tr>
				</tbody>
			</table>
		</div>
	</section>

</body>
	
<script type="text/javascript">

$treeTable.addTreeTable($hostconfig.sysAuthHost+"/menu/list?user_guid="+$byking.getCookieValue("user_guid"), '#menuMaintain', function (index, type, event) {
	if (type === 'addParent') {
		var title = "新增菜单";
		var url = "authority/menu/addmenu.html";
		var area = ["500px", "400px"];
		$byking.showModal(title,url,area);
	} else if(type=="add"){
		var content = this.page[index];
		var title = "【"+content.menu_name+"】新增菜单";
		var url = "authority/menu/addmenu.html?guid="+content.guid;
		var area = ["500px", "400px"];
		$byking.showModal(title,url,area);
	} else if(type == "update"){
		var content = this.page[index];
		var title = "修改【"+content.menu_name+"】部门信息";
		var url = "authority/menu/modifymenu.html?guid="+content.guid;
		var area = ["500px", "400px"];
		$byking.showModal(title,url,area);
	} else if (type == "delete") {
		var rowNum = index;
		var content = this.page[rowNum];
		var index = layer.confirm("确认删除记录？", {
			  btn: ["确认", "取消"] 
			}, function(index, layero){
				var url = $hostconfig.sysAuthHost+"/menu/del?guid="+content.guid;
				$byking.getJSONWithToken(url,function(data){
					$treeTable.getVue('#menuMaintain').refreh();
					layer.close(index);
				},function(data){
					layer.msg(data.responseJSON.message, {icon: 5});
					layer.close(index);
				} );
			});
	
	}
}, 1 , null ,true ,"#menumanage");

function setData(){
	$treeTable.getVue('#menuMaintain').refreh();
}
</script>
</html>